/*
 * ReportsPanel.java
 *
 * Created on __DATE__, __TIME__
 */

package com.popsGUI.java;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;

import javax.swing.RepaintManager;
import javax.swing.table.DefaultTableModel;

import com.popsDB.java.dto.Customers;
import com.popsDB.java.dto.Items;
import com.popsDB.java.dto.Ordereditems;
import com.popsDB.java.dto.Orders;
import com.popsDB.java.dto.Pricesheets;

/**
 *
 * @author  __USER__
 */
public class ReportsPanel extends javax.swing.JPanel implements Printable {

	/** Creates new form ReportsPanel */
	public ReportsPanel() {
		initComponents();
		notificationDialog = new com.popsGUI.java.notificationDialog(null,false);
	}

	//GEN-BEGIN:initComponents
	// <editor-fold defaultstate="collapsed" desc="Generated Code">
	private void initComponents() {

		indOrderSelection_dialog = new javax.swing.JDialog();
		iosd_order_label = new javax.swing.JLabel();
		iosd_order_combobox = new javax.swing.JComboBox();
		iosd_print_button = new javax.swing.JButton();
		iosd_cancel_button = new javax.swing.JButton();
		iosd_customer_label = new javax.swing.JLabel();
		iosd_customer_combobox = new javax.swing.JComboBox();
		printPreview_dialog = new javax.swing.JDialog();
		ppd_preview_scrollpane = new javax.swing.JScrollPane();
		ppd_preview_textarea = new javax.swing.JTextArea();
		priceSheetSelection_dialog = new javax.swing.JDialog();
		pss_pst_label = new javax.swing.JLabel();
		pss_pst_combobox = new javax.swing.JComboBox();
		pss_ps_label = new javax.swing.JLabel();
		pss_ps_combobox = new javax.swing.JComboBox();
		pss_or_label = new javax.swing.JLabel();
		pss_customer_label = new javax.swing.JLabel();
		pss_customer_combobox = new javax.swing.JComboBox();
		pss_print_button = new javax.swing.JButton();
		pss_cancel_button = new javax.swing.JButton();
		pss_custNote_label = new javax.swing.JLabel();
		pss_notes_label = new javax.swing.JLabel();
		orderDateSelection_dialog = new javax.swing.JDialog();
		odsd_info1_label = new javax.swing.JLabel();
		odsd_month_combobox = new javax.swing.JComboBox();
		odsd_year_combobox = new javax.swing.JComboBox();
		odsd_month_label = new javax.swing.JLabel();
		odsd_year_label = new javax.swing.JLabel();
		odsd_day_label = new javax.swing.JLabel();
		odsd_day_combobox = new javax.swing.JComboBox();
		odsd_info2_label = new javax.swing.JLabel();
		odsd_print_button = new javax.swing.JButton();
		odsd_cancel_button = new javax.swing.JButton();
		customerSelection_dialog = new javax.swing.JDialog();
		csd_customer_label = new javax.swing.JLabel();
		csd_customer_combobox = new javax.swing.JComboBox();
		csd_print_button = new javax.swing.JButton();
		csd_cancel_button = new javax.swing.JButton();
		rp_printPriceSheet_button = new javax.swing.JButton();
		rp_printDailyOrders_button = new javax.swing.JButton();
		rp_printCustList_button = new javax.swing.JButton();
		rp_printCustInfo_button = new javax.swing.JButton();
		rp_printIndOrder_button = new javax.swing.JButton();
		rp_printMonthlyOrders_button = new javax.swing.JButton();
		rp_printDailySales_button = new javax.swing.JButton();
		rp_printMonthlySales_button = new javax.swing.JButton();
		rp_priceSheets_label = new javax.swing.JLabel();
		jSeparator1 = new javax.swing.JSeparator();
		rp_orders_label = new javax.swing.JLabel();
		jSeparator2 = new javax.swing.JSeparator();
		rp_customers_label = new javax.swing.JLabel();
		jSeparator3 = new javax.swing.JSeparator();
		rp_sales_label = new javax.swing.JLabel();

		indOrderSelection_dialog
				.setMinimumSize(new java.awt.Dimension(400, 300));

		iosd_order_label
				.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		iosd_order_label.setText("Select an order");
		iosd_order_label
				.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

		iosd_print_button.setText("Print");
		iosd_print_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						iosd_print_buttonActionPerformed(evt);
					}
				});

		iosd_cancel_button.setText("Cancel");
		iosd_cancel_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						iosd_cancel_buttonActionPerformed(evt);
					}
				});

		iosd_customer_label
				.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		iosd_customer_label.setText("Select a customer");

		iosd_customer_combobox
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						iosd_customer_comboboxActionPerformed(evt);
					}
				});

		javax.swing.GroupLayout indOrderSelection_dialogLayout = new javax.swing.GroupLayout(
				indOrderSelection_dialog.getContentPane());
		indOrderSelection_dialog.getContentPane().setLayout(
				indOrderSelection_dialogLayout);
		indOrderSelection_dialogLayout
				.setHorizontalGroup(indOrderSelection_dialogLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								indOrderSelection_dialogLayout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												indOrderSelection_dialogLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addGroup(
																indOrderSelection_dialogLayout
																		.createSequentialGroup()
																		.addComponent(
																				iosd_order_combobox,
																				0,
																				376,
																				Short.MAX_VALUE)
																		.addContainerGap())
														.addGroup(
																javax.swing.GroupLayout.Alignment.TRAILING,
																indOrderSelection_dialogLayout
																		.createSequentialGroup()
																		.addGroup(
																				indOrderSelection_dialogLayout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.TRAILING)
																						.addComponent(
																								iosd_customer_combobox,
																								javax.swing.GroupLayout.Alignment.LEADING,
																								0,
																								376,
																								Short.MAX_VALUE)
																						.addComponent(
																								iosd_customer_label,
																								javax.swing.GroupLayout.Alignment.LEADING,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								376,
																								Short.MAX_VALUE)
																						.addComponent(
																								iosd_order_label,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								376,
																								Short.MAX_VALUE))
																		.addContainerGap())))
						.addGroup(
								javax.swing.GroupLayout.Alignment.TRAILING,
								indOrderSelection_dialogLayout
										.createSequentialGroup()
										.addGap(87, 87, 87)
										.addComponent(iosd_print_button)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED,
												99, Short.MAX_VALUE)
										.addComponent(iosd_cancel_button)
										.addGap(76, 76, 76)));

		indOrderSelection_dialogLayout.linkSize(
				javax.swing.SwingConstants.HORIZONTAL,
				new java.awt.Component[] { iosd_cancel_button,
						iosd_print_button });

		indOrderSelection_dialogLayout
				.setVerticalGroup(indOrderSelection_dialogLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								indOrderSelection_dialogLayout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(iosd_customer_label)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												iosd_customer_combobox,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addGap(40, 40, 40)
										.addComponent(iosd_order_label)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												iosd_order_combobox,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED,
												94, Short.MAX_VALUE)
										.addGroup(
												indOrderSelection_dialogLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																iosd_cancel_button)
														.addComponent(
																iosd_print_button))
										.addGap(38, 38, 38)));

		ppd_preview_textarea.setColumns(20);
		ppd_preview_textarea.setRows(5);
		ppd_preview_scrollpane.setViewportView(ppd_preview_textarea);

		javax.swing.GroupLayout printPreview_dialogLayout = new javax.swing.GroupLayout(
				printPreview_dialog.getContentPane());
		printPreview_dialog.getContentPane().setLayout(
				printPreview_dialogLayout);
		printPreview_dialogLayout
				.setHorizontalGroup(printPreview_dialogLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								printPreview_dialogLayout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(
												ppd_preview_scrollpane,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												376, Short.MAX_VALUE)
										.addContainerGap()));
		printPreview_dialogLayout
				.setVerticalGroup(printPreview_dialogLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								printPreview_dialogLayout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(
												ppd_preview_scrollpane,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												274, Short.MAX_VALUE)
										.addContainerGap()));

		priceSheetSelection_dialog.setMinimumSize(new java.awt.Dimension(420,
				400));

		pss_pst_label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		pss_pst_label.setText("Select a Price Sheet Template");

		pss_pst_combobox.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				pss_pst_comboboxActionPerformed(evt);
			}
		});

		pss_ps_label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		pss_ps_label.setText("Select a Price Sheet");

		pss_or_label.setFont(new java.awt.Font("Segoe UI", 0, 18));
		pss_or_label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		pss_or_label.setText("OR");

		pss_customer_label
				.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		pss_customer_label.setText("Select a customer");

		pss_print_button.setText("Print");
		pss_print_button.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				pss_print_buttonActionPerformed(evt);
			}
		});

		pss_cancel_button.setText("Cancel");
		pss_cancel_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						pss_cancel_buttonActionPerformed(evt);
					}
				});

		pss_custNote_label
				.setText("Note: Prints the selected customer's price sheet.");

		pss_notes_label
				.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		pss_notes_label
				.setText("If both price sheet and customer are selected, defaults to customer.");

		javax.swing.GroupLayout priceSheetSelection_dialogLayout = new javax.swing.GroupLayout(
				priceSheetSelection_dialog.getContentPane());
		priceSheetSelection_dialog.getContentPane().setLayout(
				priceSheetSelection_dialogLayout);
		priceSheetSelection_dialogLayout
				.setHorizontalGroup(priceSheetSelection_dialogLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								priceSheetSelection_dialogLayout
										.createSequentialGroup()
										.addGroup(
												priceSheetSelection_dialogLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addGroup(
																priceSheetSelection_dialogLayout
																		.createSequentialGroup()
																		.addContainerGap()
																		.addGroup(
																				priceSheetSelection_dialogLayout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.LEADING)
																						.addComponent(
																								pss_pst_combobox,
																								0,
																								376,
																								Short.MAX_VALUE)
																						.addComponent(
																								pss_pst_label,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								376,
																								Short.MAX_VALUE)
																						.addComponent(
																								pss_ps_label,
																								javax.swing.GroupLayout.Alignment.TRAILING,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								376,
																								Short.MAX_VALUE)
																						.addComponent(
																								pss_ps_combobox,
																								0,
																								376,
																								Short.MAX_VALUE)
																						.addComponent(
																								pss_customer_label,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								376,
																								Short.MAX_VALUE)
																						.addComponent(
																								pss_customer_combobox,
																								0,
																								376,
																								Short.MAX_VALUE)
																						.addComponent(
																								pss_or_label,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								376,
																								Short.MAX_VALUE)))
														.addGroup(
																priceSheetSelection_dialogLayout
																		.createSequentialGroup()
																		.addGap(
																				100,
																				100,
																				100)
																		.addComponent(
																				pss_print_button)
																		.addGap(
																				59,
																				59,
																				59)
																		.addComponent(
																				pss_cancel_button))
														.addGroup(
																priceSheetSelection_dialogLayout
																		.createSequentialGroup()
																		.addContainerGap()
																		.addComponent(
																				pss_custNote_label,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				376,
																				Short.MAX_VALUE))
														.addGroup(
																priceSheetSelection_dialogLayout
																		.createSequentialGroup()
																		.addContainerGap()
																		.addComponent(
																				pss_notes_label,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				376,
																				Short.MAX_VALUE)))
										.addContainerGap()));

		priceSheetSelection_dialogLayout
				.linkSize(javax.swing.SwingConstants.HORIZONTAL,
						new java.awt.Component[] { pss_cancel_button,
								pss_print_button });

		priceSheetSelection_dialogLayout
				.setVerticalGroup(priceSheetSelection_dialogLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								priceSheetSelection_dialogLayout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(pss_pst_label)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												pss_pst_combobox,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addGap(26, 26, 26)
										.addComponent(pss_ps_label)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												pss_ps_combobox,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addGap(32, 32, 32)
										.addComponent(pss_or_label)
										.addGap(18, 18, 18)
										.addComponent(pss_customer_label)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												pss_customer_combobox,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(pss_custNote_label)
										.addGap(18, 18, 18)
										.addComponent(pss_notes_label)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED,
												21, Short.MAX_VALUE)
										.addGroup(
												priceSheetSelection_dialogLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																pss_print_button)
														.addComponent(
																pss_cancel_button))
										.addGap(33, 33, 33)));

		orderDateSelection_dialog.setMinimumSize(new java.awt.Dimension(420,
				320));

		odsd_info1_label
				.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		odsd_info1_label.setText("INFO1");

		odsd_month_combobox.setModel(new javax.swing.DefaultComboBoxModel(
				new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9",
						"10", "11", "12" }));
		odsd_month_combobox
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						odsd_month_comboboxActionPerformed(evt);
					}
				});

		odsd_year_combobox.setModel(new javax.swing.DefaultComboBoxModel(
				new String[] { "2010" }));
		odsd_year_combobox
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						odsd_year_comboboxActionPerformed(evt);
					}
				});

		odsd_month_label
				.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		odsd_month_label.setText("Month");

		odsd_year_label
				.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		odsd_year_label.setText("Year");

		odsd_day_label
				.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		odsd_day_label.setText("Day");

		odsd_day_combobox.setModel(new javax.swing.DefaultComboBoxModel(
				new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9",
						"10", "11", "12", "13", "14", "15", "16", "17", "18",
						"19", "20", "21", "22", "23", "24", "25", "26", "27",
						"28", "29", "30", "31" }));

		odsd_info2_label
				.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		odsd_info2_label.setText("INFO2");

		odsd_print_button.setText("Print");
		odsd_print_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						odsd_print_buttonActionPerformed(evt);
					}
				});

		odsd_cancel_button.setText("Cancel");
		odsd_cancel_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						odsd_cancel_buttonActionPerformed(evt);
					}
				});

		javax.swing.GroupLayout orderDateSelection_dialogLayout = new javax.swing.GroupLayout(
				orderDateSelection_dialog.getContentPane());
		orderDateSelection_dialog.getContentPane().setLayout(
				orderDateSelection_dialogLayout);
		orderDateSelection_dialogLayout
				.setHorizontalGroup(orderDateSelection_dialogLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								orderDateSelection_dialogLayout
										.createSequentialGroup()
										.addGroup(
												orderDateSelection_dialogLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addGroup(
																orderDateSelection_dialogLayout
																		.createSequentialGroup()
																		.addContainerGap()
																		.addComponent(
																				odsd_info1_label,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				376,
																				Short.MAX_VALUE))
														.addGroup(
																orderDateSelection_dialogLayout
																		.createSequentialGroup()
																		.addGap(
																				135,
																				135,
																				135)
																		.addGroup(
																				orderDateSelection_dialogLayout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.LEADING)
																						.addGroup(
																								orderDateSelection_dialogLayout
																										.createSequentialGroup()
																										.addGroup(
																												orderDateSelection_dialogLayout
																														.createParallelGroup(
																																javax.swing.GroupLayout.Alignment.LEADING,
																																false)
																														.addComponent(
																																odsd_month_label,
																																javax.swing.GroupLayout.DEFAULT_SIZE,
																																javax.swing.GroupLayout.DEFAULT_SIZE,
																																Short.MAX_VALUE)
																														.addComponent(
																																odsd_month_combobox,
																																javax.swing.GroupLayout.PREFERRED_SIZE,
																																javax.swing.GroupLayout.DEFAULT_SIZE,
																																javax.swing.GroupLayout.PREFERRED_SIZE))
																										.addPreferredGap(
																												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																										.addGroup(
																												orderDateSelection_dialogLayout
																														.createParallelGroup(
																																javax.swing.GroupLayout.Alignment.LEADING,
																																false)
																														.addComponent(
																																odsd_year_label,
																																javax.swing.GroupLayout.DEFAULT_SIZE,
																																javax.swing.GroupLayout.DEFAULT_SIZE,
																																Short.MAX_VALUE)
																														.addComponent(
																																odsd_year_combobox,
																																javax.swing.GroupLayout.PREFERRED_SIZE,
																																javax.swing.GroupLayout.DEFAULT_SIZE,
																																javax.swing.GroupLayout.PREFERRED_SIZE)))
																						.addGroup(
																								orderDateSelection_dialogLayout
																										.createSequentialGroup()
																										.addGap(
																												31,
																												31,
																												31)
																										.addGroup(
																												orderDateSelection_dialogLayout
																														.createParallelGroup(
																																javax.swing.GroupLayout.Alignment.TRAILING,
																																false)
																														.addComponent(
																																odsd_day_label,
																																javax.swing.GroupLayout.Alignment.LEADING,
																																javax.swing.GroupLayout.DEFAULT_SIZE,
																																javax.swing.GroupLayout.DEFAULT_SIZE,
																																Short.MAX_VALUE)
																														.addComponent(
																																odsd_day_combobox,
																																javax.swing.GroupLayout.Alignment.LEADING,
																																javax.swing.GroupLayout.PREFERRED_SIZE,
																																javax.swing.GroupLayout.DEFAULT_SIZE,
																																javax.swing.GroupLayout.PREFERRED_SIZE)))))
														.addGroup(
																javax.swing.GroupLayout.Alignment.TRAILING,
																orderDateSelection_dialogLayout
																		.createSequentialGroup()
																		.addContainerGap()
																		.addComponent(
																				odsd_info2_label,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				376,
																				Short.MAX_VALUE))
														.addGroup(
																orderDateSelection_dialogLayout
																		.createSequentialGroup()
																		.addGap(
																				94,
																				94,
																				94)
																		.addComponent(
																				odsd_print_button)
																		.addGap(
																				64,
																				64,
																				64)
																		.addComponent(
																				odsd_cancel_button)))
										.addContainerGap()));

		orderDateSelection_dialogLayout.linkSize(
				javax.swing.SwingConstants.HORIZONTAL,
				new java.awt.Component[] { odsd_cancel_button,
						odsd_print_button });

		orderDateSelection_dialogLayout
				.setVerticalGroup(orderDateSelection_dialogLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								orderDateSelection_dialogLayout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(odsd_info1_label)
										.addGap(18, 18, 18)
										.addGroup(
												orderDateSelection_dialogLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																odsd_year_label)
														.addComponent(
																odsd_month_label))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												orderDateSelection_dialogLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																odsd_month_combobox,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE)
														.addComponent(
																odsd_year_combobox,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(odsd_day_label)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												odsd_day_combobox,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addGap(54, 54, 54)
										.addComponent(odsd_info2_label)
										.addGap(26, 26, 26)
										.addGroup(
												orderDateSelection_dialogLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																odsd_print_button)
														.addComponent(
																odsd_cancel_button))
										.addContainerGap(35, Short.MAX_VALUE)));

		customerSelection_dialog
				.setMinimumSize(new java.awt.Dimension(400, 300));

		csd_customer_label
				.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		csd_customer_label.setText("Select a Customer");

		csd_print_button.setText("Print");

		csd_cancel_button.setText("Cancel");

		javax.swing.GroupLayout customerSelection_dialogLayout = new javax.swing.GroupLayout(
				customerSelection_dialog.getContentPane());
		customerSelection_dialog.getContentPane().setLayout(
				customerSelection_dialogLayout);
		customerSelection_dialogLayout
				.setHorizontalGroup(customerSelection_dialogLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								customerSelection_dialogLayout
										.createSequentialGroup()
										.addGroup(
												customerSelection_dialogLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addGroup(
																customerSelection_dialogLayout
																		.createSequentialGroup()
																		.addContainerGap()
																		.addGroup(
																				customerSelection_dialogLayout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.TRAILING)
																						.addComponent(
																								csd_customer_combobox,
																								javax.swing.GroupLayout.Alignment.LEADING,
																								0,
																								376,
																								Short.MAX_VALUE)
																						.addComponent(
																								csd_customer_label,
																								javax.swing.GroupLayout.Alignment.LEADING,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								376,
																								Short.MAX_VALUE)))
														.addGroup(
																customerSelection_dialogLayout
																		.createSequentialGroup()
																		.addGap(
																				113,
																				113,
																				113)
																		.addComponent(
																				csd_print_button)
																		.addGap(
																				36,
																				36,
																				36)
																		.addComponent(
																				csd_cancel_button)))
										.addContainerGap()));

		customerSelection_dialogLayout
				.linkSize(javax.swing.SwingConstants.HORIZONTAL,
						new java.awt.Component[] { csd_cancel_button,
								csd_print_button });

		customerSelection_dialogLayout
				.setVerticalGroup(customerSelection_dialogLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								customerSelection_dialogLayout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(csd_customer_label)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												csd_customer_combobox,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED,
												160, Short.MAX_VALUE)
										.addGroup(
												customerSelection_dialogLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																csd_cancel_button)
														.addComponent(
																csd_print_button))
										.addGap(57, 57, 57)));

		rp_printPriceSheet_button.setText("Print Price Sheets");
		rp_printPriceSheet_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						rp_printPriceSheet_buttonActionPerformed(evt);
					}
				});

		rp_printDailyOrders_button.setText("Print Daily Orders Report");
		rp_printDailyOrders_button.setEnabled(false);
		rp_printDailyOrders_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						rp_printDailyOrders_buttonActionPerformed(evt);
					}
				});

		rp_printCustList_button.setText("Print Customer List");
		rp_printCustList_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						rp_printCustList_buttonActionPerformed(evt);
					}
				});

		rp_printCustInfo_button.setText("Print Customer Info");
		rp_printCustInfo_button.setEnabled(false);
		rp_printCustInfo_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						rp_printCustInfo_buttonActionPerformed(evt);
					}
				});

		rp_printIndOrder_button.setText("Print Individual Order");
		rp_printIndOrder_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						rp_printIndOrder_buttonActionPerformed(evt);
					}
				});

		rp_printMonthlyOrders_button.setText("Print Monthly Orders Report");
		rp_printMonthlyOrders_button.setEnabled(false);
		rp_printMonthlyOrders_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						rp_printMonthlyOrders_buttonActionPerformed(evt);
					}
				});

		rp_printDailySales_button.setText("Print Daily Sales Report");
		rp_printDailySales_button.setEnabled(false);
		rp_printDailySales_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						rp_printDailySales_buttonActionPerformed(evt);
					}
				});

		rp_printMonthlySales_button.setText("Print Monthly Sales Report");
		rp_printMonthlySales_button.setEnabled(false);
		rp_printMonthlySales_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						rp_printMonthlySales_buttonActionPerformed(evt);
					}
				});

		rp_priceSheets_label.setFont(new java.awt.Font("Segoe UI", 0, 14));
		rp_priceSheets_label
				.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		rp_priceSheets_label.setText("Price Sheets");

		rp_orders_label.setFont(new java.awt.Font("Segoe UI", 0, 14));
		rp_orders_label
				.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		rp_orders_label.setText("Orders");

		rp_customers_label.setFont(new java.awt.Font("Segoe UI", 0, 14));
		rp_customers_label
				.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		rp_customers_label.setText("Customers");

		rp_sales_label.setFont(new java.awt.Font("Segoe UI", 0, 14));
		rp_sales_label
				.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		rp_sales_label.setText("Sales");

		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
		this.setLayout(layout);
		layout
				.setHorizontalGroup(layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								layout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addComponent(
																rp_sales_label,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																1012,
																Short.MAX_VALUE)
														.addGroup(
																javax.swing.GroupLayout.Alignment.TRAILING,
																layout
																		.createSequentialGroup()
																		.addComponent(
																				rp_printPriceSheet_button)
																		.addGap(
																				448,
																				448,
																				448))
														.addGroup(
																layout
																		.createSequentialGroup()
																		.addComponent(
																				rp_printCustInfo_button)
																		.addContainerGap(
																				875,
																				Short.MAX_VALUE))
														.addGroup(
																layout
																		.createSequentialGroup()
																		.addComponent(
																				rp_printDailyOrders_button)
																		.addContainerGap(
																				831,
																				Short.MAX_VALUE))
														.addGroup(
																layout
																		.createSequentialGroup()
																		.addComponent(
																				rp_printDailySales_button)
																		.addContainerGap(
																				839,
																				Short.MAX_VALUE))
														.addGroup(
																layout
																		.createSequentialGroup()
																		.addComponent(
																				rp_printMonthlySales_button)
																		.addContainerGap(
																				839,
																				Short.MAX_VALUE))
														.addGroup(
																layout
																		.createSequentialGroup()
																		.addComponent(
																				rp_printMonthlyOrders_button)
																		.addContainerGap(
																				831,
																				Short.MAX_VALUE))))
						.addComponent(jSeparator1,
								javax.swing.GroupLayout.Alignment.TRAILING,
								javax.swing.GroupLayout.DEFAULT_SIZE, 1024,
								Short.MAX_VALUE).addComponent(jSeparator2,
								javax.swing.GroupLayout.Alignment.TRAILING,
								javax.swing.GroupLayout.DEFAULT_SIZE, 1024,
								Short.MAX_VALUE).addComponent(rp_orders_label,
								javax.swing.GroupLayout.Alignment.TRAILING,
								javax.swing.GroupLayout.DEFAULT_SIZE, 1024,
								Short.MAX_VALUE).addComponent(
								rp_priceSheets_label,
								javax.swing.GroupLayout.Alignment.TRAILING,
								javax.swing.GroupLayout.DEFAULT_SIZE, 1024,
								Short.MAX_VALUE).addComponent(jSeparator3,
								javax.swing.GroupLayout.Alignment.TRAILING,
								javax.swing.GroupLayout.DEFAULT_SIZE, 1024,
								Short.MAX_VALUE).addComponent(
								rp_customers_label,
								javax.swing.GroupLayout.Alignment.TRAILING,
								javax.swing.GroupLayout.DEFAULT_SIZE, 1024,
								Short.MAX_VALUE).addGroup(
								javax.swing.GroupLayout.Alignment.TRAILING,
								layout.createSequentialGroup().addContainerGap(
										426, Short.MAX_VALUE).addComponent(
										rp_printIndOrder_button).addGap(417,
										417, 417)).addGroup(
								layout.createSequentialGroup().addGap(444, 444,
										444).addComponent(
										rp_printCustList_button)
										.addContainerGap(443, Short.MAX_VALUE)));

		layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
				new java.awt.Component[] { rp_printDailySales_button,
						rp_printMonthlySales_button });

		layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
				new java.awt.Component[] { rp_printCustInfo_button,
						rp_printCustList_button });

		layout
				.linkSize(javax.swing.SwingConstants.HORIZONTAL,
						new java.awt.Component[] { rp_printDailyOrders_button,
								rp_printIndOrder_button,
								rp_printMonthlyOrders_button });

		layout
				.setVerticalGroup(layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								layout
										.createSequentialGroup()
										.addGap(154, 154, 154)
										.addComponent(rp_priceSheets_label)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(rp_printPriceSheet_button)
										.addGap(18, 18, 18)
										.addComponent(
												jSeparator1,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												13,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(rp_orders_label)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(rp_printIndOrder_button)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												jSeparator2,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												10,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(rp_customers_label)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(rp_printCustList_button)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												jSeparator3,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												10,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(rp_sales_label)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED,
												91, Short.MAX_VALUE)
										.addComponent(
												rp_printMonthlyOrders_button)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												rp_printMonthlySales_button)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(rp_printDailySales_button)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												rp_printDailyOrders_button)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
										.addComponent(rp_printCustInfo_button)
										.addContainerGap()));
	}// </editor-fold>
	//GEN-END:initComponents

	private void odsd_month_comboboxActionPerformed(
			java.awt.event.ActionEvent evt) {
		odsd_day_combobox.removeAllItems();

		int monthSelected = Integer.parseInt((String) odsd_month_combobox
				.getSelectedItem());

		for (int i = 1; i <= DAYS[monthSelected - 1]; i++) {
			odsd_day_combobox.addItem(i);
		}
		Calendar cal = dateFormat.getCalendar();

		// If it's february and a leap year, we need to add a 29th day
		if (monthSelected == cal.FEBRUARY) {
			if (this.isLeapYear((Integer) odsd_year_combobox.getSelectedItem())) {
				odsd_day_combobox.addItem(29);
			}
		}
	}

	private void odsd_year_comboboxActionPerformed(
			java.awt.event.ActionEvent evt) {

		int year;
		Calendar cal = dateFormat.getCalendar();

		// Need this because exceptions get thrown otherwise
		if (odsd_year_combobox.getSelectedItem() != null) {
			year = (Integer) odsd_year_combobox.getSelectedItem();
		} else {
			Date curDate = new Date();
			year = curDate.getYear();
		}

		if (this.isLeapYear(year)) {
			// If it's a leap year, we need to add a day if february is selected
			if (Integer
					.parseInt((String) odsd_month_combobox.getSelectedItem()) == cal.FEBRUARY) {
				odsd_month_combobox.addItem(29);
			}
		}

	}

	// Algorithm to determine leap year according to:
	// http://en.wikipedia.org/wiki/Leap_year
	private boolean isLeapYear(int year) {
		return (year % 400 == 0 || year % 4 == 0 && year % 100 != 0);
	}

	private void odsd_print_buttonActionPerformed(java.awt.event.ActionEvent evt) {
		// TODO add your handling code here
		if (odsd_info1_label.getText() == DAILY) {
			if (odsd_day_combobox.getSelectedItem() != null
					&& odsd_month_combobox.getSelectedItem() != null
					&& odsd_year_combobox.getSelectedItem() != null) {
				Calendar cal = dateFormat.getCalendar();
				System.out.println("Calendar string: " + cal.toString());
				System.out.println("Calenar.getTime(): " + cal.getTime());
				String dateString = (String) odsd_month_combobox
						.getSelectedItem()
						+ "/";
				dateString += (String) odsd_day_combobox.getSelectedItem()
						+ "/";
				dateString += (Integer) odsd_year_combobox.getSelectedItem();
				dateString += " 00:00";
				Date curDate = cal.getTime();
				curDate.toString();
				System.out.println("dateString: " + dateString);
				try {
					System.out.println("the parse: "
							+ dateFormat.parse(dateString));
				} catch (ParseException e) {
					// TODO Auto-generated catch block
					System.out.println("Parse Exception: " + e);
					e.printStackTrace();
				}
			}
		} else { //MONTHLY

		}
	}

	private void odsd_cancel_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {
		this.orderDateSelection_dialog.setVisible(false);
	}

	private void iosd_customer_comboboxActionPerformed(
			java.awt.event.ActionEvent evt) {
		// clear iosd_order_combobox so we can add the appropriate items
		iosd_order_combobox.removeAllItems();
		// If not null then we find orders from the selected customer and add it to the list
		if (this.iosd_customer_combobox.getSelectedItem() != null) {
			int custID = MEDIATOR.getCustomerID((String) iosd_customer_combobox
					.getSelectedItem());

			iosd_order_combobox.addItem(null);
			String[] orders = MEDIATOR.findOrdersByCustID(custID);
			for (int i = 0; i < orders.length; i++) {
				iosd_order_combobox.addItem(orders[i]);
			}
		} else { // No customer selected
			iosd_order_combobox.addItem(DEFAULT_ORDER);
		}
	}

	private void iosd_cancel_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {
		this.indOrderSelection_dialog.setVisible(false);
	}

	private void iosd_print_buttonActionPerformed(java.awt.event.ActionEvent evt) {
		if (this.iosd_order_combobox.getSelectedItem() != null
				&& !((String) iosd_order_combobox.getSelectedItem())
						.equals(DEFAULT_ORDER)) {
			int ordID = Integer.parseInt((String) iosd_order_combobox
					.getSelectedItem());

			this.printOrder(ordID);
		} else {
			notificationDialog.displayNotification("Please select an order before printing.");
		}
	}

	private void pss_pst_comboboxActionPerformed(java.awt.event.ActionEvent evt) {
		//////////////////
		//check if empty//
		//////////////////
		if (this.pss_pst_combobox.getSelectedItem() != null) {

			///////////////////
			//try to get PSid//
			///////////////////
			int PSTid = MEDIATOR.getPSid((String) this.pss_pst_combobox
					.getSelectedItem());
			if (PSTid == -1) {
				System.out.println("ERROR in pss_pst_comboboxActionPerformed");
			} else {
				//////////////////
				// then display //
				//////////////////
				this.loadPSComboboxWithChildrenOf(PSTid);
			}
		} else {
			this.fillPSCombobox();
		}
	}

	public void loadPSComboboxWithChildrenOf(int PSTid) {
		this.pss_ps_combobox.removeAllItems();

		Pricesheets[] children = MEDIATOR.getAllChildrenOfPST(PSTid);

		this.pss_ps_combobox.addItem(null);
		for (int i = 0; i < children.length; i++) {
			this.pss_ps_combobox.addItem(children[i].getPriceSheetName());
		}
	}

	// Fills pss_ps_combobox with appropriate values
	public void fillPSCombobox() {
		this.pss_ps_combobox.removeAllItems();

		ArrayList<Pricesheets> PSsList = MEDIATOR.getPriceSheets();
		this.pss_ps_combobox.addItem(null);
		for (int i = 0; i < PSsList.size(); i++) {
			this.pss_ps_combobox.addItem(PSsList.get(i).getPriceSheetName());
		}
	}

	// Fills pss_pst_combobox with appropriate values
	public void fillPSTCombobox() {
		this.pss_pst_combobox.removeAllItems();

		ArrayList<Pricesheets> PSTList = MEDIATOR.getPriceSheetTemplates();

		this.pss_pst_combobox.addItem(null);
		for (int i = 0; i < PSTList.size(); i++) {
			this.pss_pst_combobox.addItem(PSTList.get(i).getPriceSheetName());
		}
	}

	private void pss_print_buttonActionPerformed(java.awt.event.ActionEvent evt) {
		if (this.pss_customer_combobox.getSelectedItem() != null) {
			int custID = MEDIATOR.getCustomerID((String) pss_customer_combobox
					.getSelectedItem());

			int psID = MEDIATOR.getCustomerPriceSheetID(custID);
			this.printPriceSheet(psID);
		} else if (this.pss_ps_combobox.getSelectedItem() != null) {
			int psID = MEDIATOR.getPSid((String) pss_ps_combobox
					.getSelectedItem());
			this.printPriceSheet(psID);
		} else if (this.pss_pst_combobox.getSelectedItem() != null) {
			int psID = MEDIATOR.getPSid((String) pss_pst_combobox
					.getSelectedItem());
			this.printPriceSheet(psID);
		} else { // Nothing was selected...
			notificationDialog.displayNotification("Please select a Price Sheet or Customer");
		}
	}

	private void pss_cancel_buttonActionPerformed(java.awt.event.ActionEvent evt) {
		this.priceSheetSelection_dialog.setVisible(false);
	}

	private void rp_printMonthlySales_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
	}

	private void rp_printDailySales_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
	}

	private void rp_printCustList_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {
		this.printCustList();
	}

	private void rp_printCustInfo_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
	}

	private void rp_printMonthlyOrders_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {
		this.orderDateSelection_dialog.setVisible(true);
		this.odsd_info1_label.setText(MONTHLY);
		this.odsd_info2_label.setText("Select a month and year");
		this.odsd_day_label.setVisible(false);
		this.odsd_day_combobox.setEnabled(false);
		this.odsd_day_combobox.setVisible(false);

		this.fillODSDComboboxes();
	}

	private void rp_printDailyOrders_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {
		this.orderDateSelection_dialog.setVisible(true);
		this.odsd_info1_label.setText(DAILY);
		this.odsd_info2_label.setText("Select a day, month, and year");
		this.odsd_day_label.setVisible(true);
		this.odsd_day_combobox.setEnabled(true);
		this.odsd_day_combobox.setVisible(true);

		this.fillODSDComboboxes();
	}

	@SuppressWarnings("deprecation")
	private void fillODSDComboboxes() {
		odsd_year_combobox.removeAllItems();
		Date curDate = new Date();
		for (int i = curDate.getYear(); i >= 100; i--) {
			odsd_year_combobox.addItem(i + 1900);
			odsd_year_combobox.setSelectedIndex(0);
		}
	}

	private void rp_printIndOrder_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {
		this.indOrderSelection_dialog.setVisible(true);
		this.fillIOSDCustCombobox();
	}

	// Fills iosd_customer_combobox with all customers
	public void fillIOSDCustCombobox() {
		this.iosd_customer_combobox.removeAllItems();

		String[] custList = MEDIATOR.getCustomerEditNames();
		this.iosd_customer_combobox.addItem(null);
		for (int i = 0; i < custList.length; i++) {
			this.iosd_customer_combobox.addItem(custList[i]);
		}

		this.iosd_order_combobox.removeAllItems();
		this.iosd_order_combobox.addItem(DEFAULT_ORDER);
	}

	private void rp_printPriceSheet_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {
		this.priceSheetSelection_dialog.setVisible(true);
		this.fillPSSD_comboboxes();
	}

	//GEN-BEGIN:variables
	// Variables declaration - do not modify
	private javax.swing.JButton csd_cancel_button;
	private javax.swing.JComboBox csd_customer_combobox;
	private javax.swing.JLabel csd_customer_label;
	private javax.swing.JButton csd_print_button;
	private javax.swing.JDialog customerSelection_dialog;
	private javax.swing.JDialog indOrderSelection_dialog;
	private javax.swing.JButton iosd_cancel_button;
	private javax.swing.JComboBox iosd_customer_combobox;
	private javax.swing.JLabel iosd_customer_label;
	private javax.swing.JComboBox iosd_order_combobox;
	private javax.swing.JLabel iosd_order_label;
	private javax.swing.JButton iosd_print_button;
	private javax.swing.JSeparator jSeparator1;
	private javax.swing.JSeparator jSeparator2;
	private javax.swing.JSeparator jSeparator3;
	private javax.swing.JButton odsd_cancel_button;
	private javax.swing.JComboBox odsd_day_combobox;
	private javax.swing.JLabel odsd_day_label;
	private javax.swing.JLabel odsd_info1_label;
	private javax.swing.JLabel odsd_info2_label;
	private javax.swing.JComboBox odsd_month_combobox;
	private javax.swing.JLabel odsd_month_label;
	private javax.swing.JButton odsd_print_button;
	private javax.swing.JComboBox odsd_year_combobox;
	private javax.swing.JLabel odsd_year_label;
	private javax.swing.JDialog orderDateSelection_dialog;
	private javax.swing.JScrollPane ppd_preview_scrollpane;
	private javax.swing.JTextArea ppd_preview_textarea;
	private javax.swing.JDialog priceSheetSelection_dialog;
	private javax.swing.JDialog printPreview_dialog;
	private javax.swing.JButton pss_cancel_button;
	private javax.swing.JLabel pss_custNote_label;
	private javax.swing.JComboBox pss_customer_combobox;
	private javax.swing.JLabel pss_customer_label;
	private javax.swing.JLabel pss_notes_label;
	private javax.swing.JLabel pss_or_label;
	private javax.swing.JButton pss_print_button;
	private javax.swing.JComboBox pss_ps_combobox;
	private javax.swing.JLabel pss_ps_label;
	private javax.swing.JComboBox pss_pst_combobox;
	private javax.swing.JLabel pss_pst_label;
	private javax.swing.JLabel rp_customers_label;
	private javax.swing.JLabel rp_orders_label;
	private javax.swing.JLabel rp_priceSheets_label;
	private javax.swing.JButton rp_printCustInfo_button;
	private javax.swing.JButton rp_printCustList_button;
	private javax.swing.JButton rp_printDailyOrders_button;
	private javax.swing.JButton rp_printDailySales_button;
	private javax.swing.JButton rp_printIndOrder_button;
	private javax.swing.JButton rp_printMonthlyOrders_button;
	private javax.swing.JButton rp_printMonthlySales_button;
	private javax.swing.JButton rp_printPriceSheet_button;
	private javax.swing.JLabel rp_sales_label;
	// End of variables declaration//GEN-END:variables

	private com.popsGUI.java.notificationDialog notificationDialog;
	//////////////////////////////////////////////////////////////////
	//               Start of our variable declarations             //
	//////////////////////////////////////////////////////////////////

	Mediator MEDIATOR = Mediator.getInstance();

	DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm");
	DecimalFormat decimalPriceFormat = new DecimalFormat("###,###,##0.00");

	final String PS_HEADER = "\nItem ID \tName \t\t\t\tUnit 1\tPrice 1\tUnit2\tPrice 2\n";
	final String ITEM_HEADER = "\nItem ID \tName \t\t\t\tUnit \tQuantity \tItem Price \tSubtotal\n";
	final int MAX_TABS = 4;
	final int TAB_LENGTH = 13;

	final String DEFAULT_ORDER = "Select a customer from above...";

	final String MONTHLY = "Monthly Order Reports";
	final String DAILY = "Daily Order Reports";

	// # of days in each month of the year
	final int[] DAYS = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

	final int MONTHS = 12;

	//////////////////////////////////////////////////////////////////
	//               End of our variable declarations               //
	//////////////////////////////////////////////////////////////////

	//////////////////////////////////////////////////////////////////
	//                       Start of our code                      //
	//////////////////////////////////////////////////////////////////

	// Populates the comboboxes in priceSheetSelection_dialog
	public void fillPSSD_comboboxes() {
		this.fillPSTCombobox();
		this.fillPSCombobox();

		// Clears the combobox
		pss_customer_combobox.removeAllItems();

		// Adds all the customers to the list
		pss_customer_combobox.addItem(null);
		String[] newCustList = MEDIATOR.getCustomerNames();
		for (int i = 0; i < newCustList.length; i++) {
			pss_customer_combobox.addItem(newCustList[i]);
		}
	}

	// Disables/enables all interactive components in this panel
	public void setReportsPanelComponentsEnabledParameterTo(boolean enabled) {
		rp_printCustInfo_button.setEnabled(enabled);
		rp_printCustList_button.setEnabled(enabled);
		rp_printDailyOrders_button.setEnabled(enabled);
		rp_printIndOrder_button.setEnabled(enabled);
		rp_printMonthlyOrders_button.setEnabled(enabled);
		rp_printPriceSheet_button.setEnabled(enabled);

		//TODO: fix when daily/monthly sales & daily/monthly are implemented
		rp_printDailySales_button.setEnabled(false);
		rp_printDailySales_button.setVisible(false);
		rp_printMonthlySales_button.setEnabled(false);
		rp_printMonthlySales_button.setVisible(false);
		rp_sales_label.setVisible(false);
		this.rp_printDailyOrders_button.setEnabled(false);
		this.rp_printDailyOrders_button.setVisible(false);
		this.rp_printMonthlyOrders_button.setEnabled(false);
		this.rp_printMonthlyOrders_button.setVisible(false);
		this.rp_printCustInfo_button.setEnabled(false);
		this.rp_printCustInfo_button.setVisible(false);
	}

	public void showPriceSheetSelectionDialog() {
		this.priceSheetSelection_dialog.setVisible(true);
	}

	public void showIndOrderSelectionDialog() {
		this.indOrderSelection_dialog.setVisible(true);
	}

	/////////////////////////////////////////////////////
	///////////// Start of printing methods /////////////
	/////////////////////////////////////////////////////

	// Prints a complete list of customers
	public void printCustList() {
		//TODO complete customer list printer
		ArrayList<Customers> custList = MEDIATOR.getCustomerEditList();
		String customers = "\t\tCustomer List\n\n";
		customers += "ID \tName\t\t\t\tActive\n";
		for (int i = 0; i < custList.size(); i++) {
			// ID
			customers += custList.get(i).getCustomerID() + "\t";

			// Name
			String name = custList.get(i).getCustomerName();
			int tabs = MAX_TABS - (name.length() / TAB_LENGTH);
			customers += name;
			for (int j = 0; j < tabs; j++) {
				customers += "\t";
			}

			// Status
			if (custList.get(i).getIsActive() == 1) {
				customers += "Yes\n";
			} else {
				customers += "No\n";
			}
		}

		this.ppd_preview_textarea.setText(customers);
		componentToBePrinted = this.ppd_preview_textarea;

		// If I don't set the dialog visible it won't print
		// For some reason, this works...
		this.printPreview_dialog.setVisible(true);
		this.printPreview_dialog.setVisible(false);

		this.print();
	}

	// Prints an order with the given ID
	public void printOrder(int orderID) {
		//TODO order printer
		// Get the list of items and the order itself
		Ordereditems[] items = MEDIATOR.getOrderedItems(orderID);
		Orders ord = MEDIATOR.getOrderWithID(orderID);
		int custIndex = MEDIATOR.getCustomerEditListNumber(ord.getCustomerID());

		// Fill out order/customer information
		String order = "Order ID: " + orderID + "\n";
		if (ord.getStatus() == 1) {
			order += "Order status: Shipped\n";
		} else {
			order += "Order status: Pending...\n";
		}
		order += "Customer Name: " + MEDIATOR.getCustomerEditName(custIndex)
				+ "\n";
		order += "Customer ID: " + ord.getCustomerID() + "\n";
		order += "Address: \t" + MEDIATOR.getCustomerEditAddress1(custIndex)
				+ "\n";
		order += "\t" + MEDIATOR.getCustomerEditAddress2(custIndex) + "\n";
		order += "\t" + MEDIATOR.getCustomerEditCity(custIndex) + ", ";
		order += MEDIATOR.getCustomerEditState(custIndex) + "\n";
		order += "Notes: " + ord.getNotes() + "\n";
		order += "Directions: " + MEDIATOR.getCustomerEditDirections(custIndex)
				+ "\n";
		order += "Entered by " + MEDIATOR.getEmployeeName(ord.getEnteredByID());
		order += " on " + ord.getEnteredTime() + "\n";
		if (ord.getStatus() == 1) {
			order += "Shipped on " + ord.getShipmentDate() + "\n";
		}

		// Fill out ordered items
		order += ITEM_HEADER;

		float total = 0;
		int numItems = items.length;
		for (int i = 0; i < items.length; i++) {
			// Item ID
			order += items[i].getItemID() + "\t";

			// Name
			String name = MEDIATOR.getItemName(items[i].getItemID());
			order += name;
			int tabs = MAX_TABS - (name.length() / TAB_LENGTH);
			for (int j = 0; j < tabs; j++) {
				order += "\t";
			}

			// Unit
			order += items[i].getItemUnit() + "\t";

			// Quantity
			int quantity = items[i].getQuantityOrdered();
			order += quantity + "\t";

			// Item Price
			Float price = (Float) items[i].getPriceAtPurchase();
			order += decimalPriceFormat.format(price.doubleValue()) + "\t";

			// Sub-total
			Float subTotal = quantity * price;
			order += decimalPriceFormat.format(subTotal.doubleValue()) + "\n";
			total += subTotal;
		}

		order += "\nTotal: $"
				+ this.decimalPriceFormat.format(((Float) total).doubleValue());

		this.ppd_preview_textarea.setText(order);
		componentToBePrinted = this.ppd_preview_textarea;

		// If I don't set the dialog visible it won't print
		// For some reason, this works...
		this.printPreview_dialog.setVisible(true);
		this.printPreview_dialog.setVisible(false);

		this.print();

		indOrderSelection_dialog.setVisible(false);
	}

	// Prints a price sheet with the given price sheet ID
	public void printPriceSheet(int psID) {
		// TODO: price sheet printer 
		// 1) Use mediator to fill values in pstd_item_table
		// 2) Save values in the table to a String
		// 3) Set that string into a text area
		// 4) set componentToBePrinted = textArea
		// 5) call this.print();

		String priceSheet = "Price Sheet Name: " + MEDIATOR.getPSname(psID)
				+ "\n";
		priceSheet += "Price Sheet ID: " + psID + "\n";
		priceSheet += PS_HEADER;

		ArrayList<Items> itemList = MEDIATOR.getCompleteListOfPrices(psID);

		for (int i = 0; i < itemList.size(); i++) {
			// Item ID
			priceSheet += itemList.get(i).getItemID() + "\t";

			// Name
			priceSheet += itemList.get(i).getItemName();
			int tabs = MAX_TABS
					- (itemList.get(i).getItemName().length() / TAB_LENGTH);
			for (int j = 0; j < tabs; j++) {
				priceSheet += "\t";
			}

			// Unit 1
			priceSheet += itemList.get(i).getUnitName() + "\t";

			// Price 1
			Float price1 = (Float) itemList.get(i).getUnitPrice();
			priceSheet += this.decimalPriceFormat.format(price1.doubleValue())
					+ "\t";

			// Unit 2
			priceSheet += itemList.get(i).getOtherUnitName() + "\t";

			// Price 2
			Float price2 = (Float) itemList.get(i).getOtherUnitPrice();
			priceSheet += this.decimalPriceFormat.format(price2.doubleValue())
					+ "\n";
		}

		this.ppd_preview_textarea.setText(priceSheet);
		componentToBePrinted = this.ppd_preview_textarea;

		// If I don't set the dialog visible it won't print
		// For some reason, this works...
		this.printPreview_dialog.setVisible(true);
		this.printPreview_dialog.setVisible(false);

		this.print();

		this.priceSheetSelection_dialog.setVisible(false);
	}

	private Component componentToBePrinted;

	public void print() {
		PrinterJob printJob = PrinterJob.getPrinterJob();
		printJob.setPrintable(this);
		if (printJob.printDialog())
			try {
				System.out.println("Calling PrintJob.print()");
				printJob.print();
				System.out.println("End PrintJob.print()");
			} catch (PrinterException pe) {
				System.out.println("Error printing: " + pe);
			}
	}

	public int print(Graphics g, PageFormat pf, int pageIndex) {
		int response = NO_SUCH_PAGE;

		Graphics2D g2 = (Graphics2D) g;

		//  for faster printing, turn off double buffering
		disableDoubleBuffering(componentToBePrinted);

		Dimension d = componentToBePrinted.getSize(); //get size of document
		double panelWidth = d.width; //width in pixels
		double panelHeight = d.height; //height in pixels

		double pageHeight = pf.getImageableHeight(); //height of printer page
		double pageWidth = pf.getImageableWidth(); //width of printer page

		double scale = pageWidth / panelWidth;
		int totalNumPages = (int) Math.ceil(scale * panelHeight / pageHeight);

		//  make sure not print empty pages
		if (pageIndex >= totalNumPages) {
			response = NO_SUCH_PAGE;
		} else {

			//  shift Graphic to line up with beginning of print-imageable region
			g2.translate(pf.getImageableX(), pf.getImageableY());

			//  shift Graphic to line up with beginning of next page to print
			g2.translate(0f, -pageIndex * pageHeight);

			//  scale the page so the width fits...
			g2.scale(scale, scale);

			componentToBePrinted.paint(g2); //repaint the page for printing

			enableDoubleBuffering(componentToBePrinted);
			response = Printable.PAGE_EXISTS;
		}
		return response;
	}

	public static void disableDoubleBuffering(Component c) {
		RepaintManager currentManager = RepaintManager.currentManager(c);
		currentManager.setDoubleBufferingEnabled(false);
	}

	public static void enableDoubleBuffering(Component c) {
		RepaintManager currentManager = RepaintManager.currentManager(c);
		currentManager.setDoubleBufferingEnabled(true);
	}
}
